package com.tamo.ppresta.util;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

/**
 * @author yeyang
 * @name ppresta
 * @class name：com.tamo.ppresta.util
 * @class describe
 * @time 2022/12/24 16:08
 * @change
 * @chang time
 * @class describe
 */
public class ThirdApp {
    /**
     * 跳转到whatsApp
     *
     * @param context
     * @param mobileNum
     */
    public static void chatInWhatsApp(Context context, String mobileNum) {
        try {
            final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://api.whatsapp.com/send?phone=" + mobileNum));
            intent.setPackage("com.whatsapp");
            context.startActivity(intent);
        } catch (Exception e) { //  没有安装WhatsApp
            ToastUtil.showShort(context, "whatsapp is not install");
            e.printStackTrace();
        }
    }

    /**
     * 跳转到拨号页面
     *
     * @param context
     * @param phoneNumber
     */
    public static void callPhone(Context context, String phoneNumber) {
        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    }
} 